package com.xxx.config;

import lombok.Data;

/**
 * @author George
 * 异常处理
 */
@Data
public class Request {

    private int Code;//  编码  200  ：失败
    private String msg;//   成功 ：失败
    private Long total;// 返回总条数
    private Object data;//  200 成功 ：400 失败

    public static Request error(String error){
        return request(400,error, 0L,null);
    }
    public static Request suc(){
        return request(200,"成功", 0L,null);
    }
    public static Request suc(Object data){
        return request(200,"成功", 0L,data);
    }
    public static Request suc(Long total, Object data){
        return request(200,"成功", total,data);
    }


    private static Request request(int code, String msg, Long total, Object data){
        Request rest = new Request();
        rest.setCode(code);
        rest.setMsg(msg);
        rest.setTotal(total);
        rest.setData(data);
        return rest;
    }

}
